﻿@namespace BootstrapBlazor.Components
@typeparam TModel
@inherits DialogBase<TModel>

<ValidateForm Model="@Model" OnValidSubmit="@OnValidSubmitAsync" DisableAutoSubmitFormByEnter="@DisableAutoSubmitFormByEnter">
    @if (BodyTemplate != null)
    {
        <div class="form-body">
            @BodyTemplate(Model)
        </div>
        <div class="form-footer">
            @if (!IsTracking)
            {
                <Button Color="Color.Secondary" Icon="fa-solid fa-xmark" Text="@CloseButtonText" OnClickWithoutRender="OnClose" />
            }
            <Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="@SaveButtonText" />
        </div>
    }
    else
    {
        <EditorForm TModel="TModel" Items="Items" ItemChangedType="ItemChangedType" ItemsPerRow="ItemsPerRow" RowType="RowType" LabelAlign="LabelAlign" ShowLabel="ShowLabel" ShowUnsetGroupItemsOnTop="ShowUnsetGroupItemsOnTop">
            <Buttons>
                @if (!IsTracking)
                {
                    <Button Color="Color.Secondary" Icon="fa-solid fa-xmark" Text="@CloseButtonText" OnClickWithoutRender="OnClose" />
                }
                <Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="@SaveButtonText" />
            </Buttons>
        </EditorForm>
    }
</ValidateForm>
<div class="form-loader" @ref="SpinnerElement">
    <Spinner Color="Color.Primary" />
</div>
